{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-09-09T07:35:27.503037Z",
     "start_time": "2025-09-09T07:35:26.660669Z"
    }
   },
   "source": "from sklearn.linear_model import LogisticRegression",
   "outputs": [],
   "execution_count": 1
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-09T07:35:27.519006Z",
     "start_time": "2025-09-09T07:35:27.512059Z"
    }
   },
   "cell_type": "code",
   "source": [
    "model = LogisticRegression(\n",
    "    solver= 'sag',\n",
    "    multi_class='multinomial',\n",
    "    max_iter=1000,\n",
    "    class_weight='balanced',\n",
    "    random_state=42,\n",
    "    penalty='l2',\n",
    "    C = 1.0\n",
    ")"
   ],
   "id": "642fb8401416392f",
   "outputs": [],
   "execution_count": 2
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-09T07:35:27.526667Z",
     "start_time": "2025-09-09T07:35:27.520013Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#OVR\n",
    "#1.直接创建LogisticRegression模型\n",
    "model_ovr1 = LogisticRegression(multi_class='ovr')\n",
    "\n",
    "from sklearn.multiclass import OneVsRestClassifier, OneVsOneClassifier\n",
    "\n",
    "#2.创建OneVsRestClassifier\n",
    "model_ovr_2= OneVsRestClassifier(LogisticRegression())"
   ],
   "id": "1b75434ee93c3af",
   "outputs": [],
   "execution_count": 3
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": [
    "#Softmax逻辑回归\n",
    "model_softmax= LogisticRegression(solver='sag',multi_class='multinomial')\n"
   ],
   "id": "7c4c177cd2270c2b"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
